package com.kun.demo03;

import org.junit.Test;

//线程礼让，重新进入就绪态，让出CPU资源
public class TestYield {

    @Test
    public void testYield() throws InterruptedException {
        new Thread(() -> {
            System.out.println(Thread.currentThread().getName() + " 线程启动");
            Thread.yield();
            System.out.println(Thread.currentThread().getName() + " 线程结束");
        }, "a").start();

        new Thread(() -> {
            System.out.println(Thread.currentThread().getName() + " 线程启动");
            Thread.yield();
            System.out.println(Thread.currentThread().getName() + " 线程结束");
        }, "b").start();

    }




}
